import { getExamlistApi, setExamDataApi, delDataApi } from "@/api/exam.js"

import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)


export default {
    state: {
        ExamList: [],
        currentpage: 1,
        pagesize: 5,
        total: 0
    },
    mutations: {
        SET_EXAMLIST(state, v) {
            state.ExamList = v.data
            state.total = v.total
        },
        SET_CURRENTPAGE(state, v) {
            console.log(v);
            state.currentpage = v
        },
        SET_PAGESIZE(state, v) {
            console.log(v);
            state.pagesize = v
        },
    },
    actions: {
        async getExamlist({ commit, state }, v) {
            let r = await getExamlistApi({ currentPage: state.currentpage - 1, pageSize: state.pagesize ,serch:v })
            commit('SET_EXAMLIST', r)
        },
        async setExamData({ commit }, v) {
            let r = await setExamDataApi(v)
            console.log(r);
        },
        async delData({ commit }, v) {
            await delDataApi(v)
        }
    },
    namespaced: true
}
